<?php /*a:4:{s:60:"/www/wwwroot/yinglinet.cn/app/admin/view/basic/wxconfig.html";i:1699343568;s:57:"/www/wwwroot/yinglinet.cn/app/admin/view/base/header.html";i:1699343568;s:57:"/www/wwwroot/yinglinet.cn/app/admin/view/base/footer.html";i:1699343568;s:57:"/www/wwwroot/yinglinet.cn/app/admin/view/base/unitjs.html";i:1699343568;}*/ ?>
<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>项目</title>
    <link rel="stylesheet" href="/static/component/pear/css/pear.css">
    <link rel="stylesheet" href="/static/component/code/css/style.css">
        <script src="/static/user/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/component/layui/layui.js"></script>
    <script src="/static/component/pear/pear.js"></script>
</head>

<body class="pear-container">
      <style>
        .bkClass{
            background-color: #000!important;
        }
        .uploadSource_img {

width: 80px;

height: 80px;

line-height: 80px;

margin-right: 10px;

border: 1px dashed #ededed;

text-align: center;

color: #dad9d9;

float: left;

position: relative;

cursor: pointer;

background: white;

}

.uploadSource_img{

width: 80px;

height:80px;

}     .userp_1{
            position: relative;
        }
        .userp_2{
            position:absolute;
            right:20px;
            top:8px;
            font-weight: bold;
        }
      </style>
        <div class="layui-card"></div>
        <div class="layui-card layui-col-md6">
            <div class="layui-card">
                <div class="layui-card-header">微信小程序配置</div>
            </div>
            <div class="layui-card-body">
                <form class="layui-form " id="formId">
                    <div class="layui-form-item">
                      <label class="layui-form-label">小程序名称</label>
                      <div class="layui-input-block">
                        <input type="text" name="name" value="<?php echo htmlentities((isset($msg['name']) && ($msg['name'] !== '')?$msg['name']:'')); ?>" required  lay-verify="required" placeholder="请输入小程序名称" autocomplete="off" class="layui-input">
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">APPID</label>
                      <div class="layui-input-block">
                        <input type="text" name="appid" value="<?php echo htmlentities((isset($msg['appid']) && ($msg['appid'] !== '')?$msg['appid']:'')); ?>" required  lay-verify="required" placeholder="请输入APPID" autocomplete="off" class="layui-input">
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">SECRET</label>
                      <div class="layui-input-block">
                        <input type="text" name="secret" value="<?php echo htmlentities((isset($msg['secret']) && ($msg['secret'] !== '')?$msg['secret']:'')); ?>" required  lay-verify="required" placeholder="请输入SECRET" autocomplete="off" class="layui-input">
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">支付商户ID</label>
                      <div class="layui-input-block">
                        <input type="text" name="mch_id" value="<?php echo htmlentities((isset($msg['mch_id']) && ($msg['mch_id'] !== '')?$msg['mch_id']:'')); ?>" required  lay-verify="required" placeholder="请输入支付商户ID" autocomplete="off" class="layui-input">
                      </div>
                    </div>
                    <div class="layui-form-item">
                      <label class="layui-form-label">商户KEY</label>
                      <div class="layui-input-block">
                        <input type="text" name="key" value="<?php echo htmlentities((isset($msg['key']) && ($msg['key'] !== '')?$msg['key']:'')); ?>" required  lay-verify="required" placeholder="请输入商户KEY" autocomplete="off" class="layui-input">
                      </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">cert证书上传</label>
                        <div class="layui-input-block">
                            <?php if(!$msg['keyfile']): ?>
                                <button  type="button" class="tag-item tag-item-warm layui-btn layui-btn-default layui-btn-xs upFileClass" style="margin-top: 10px;">上传</button>
                            <?php else: ?> 
                                <button type="button" style="margin-top: 10px;" class="tag-item tag-item-warm bkClass layui-btn layui-btn-default layui-btn-xs upFileClass"
                                    >已上传</button>
                                    <a  style="margin-top: 10px;background-color:#36b368 !important;" plain class="tag-item tag-item-warm layui-btn layui-btn-default layui-btn-xs"
                                    href="/static/efile/wxconfig/<?php echo htmlentities($msg['keyfile']); ?>"  target="_blank"
                                    >下载</a>
                                    <?php endif; ?>
                            <input name="keyfile" type="file" style="display:none;" id="keyfileId">
                            
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">key证书上传</label>
                        <div class="layui-input-block">
                            <?php if(!$msg['keyfile']): ?>
                            <button type="button" class="tag-item tag-item-warm layui-btn layui-btn-default layui-btn-xs upFileClass1" style="margin-top: 10px;">上传</button>
                            <?php else: ?> 
                            <button type="button" class="tag-item tag-item-warm bkClass layui-btn layui-btn-default layui-btn-xs upFileClass1"
                                style="margin-top: 10px;">已上传</button>
                                <a  style="margin-top: 10px;background-color:#36b368 !important;" plain class="tag-item tag-item-warm layui-btn layui-btn-default layui-btn-xs"
                                    href="/static/efile/wxconfig/<?php echo htmlentities($msg['keyfile1']); ?>"  target="_blank"
                                    >下载</a>
                            <?php endif; ?>
                            <input name="keyfile1" type="file" style="display:none;"  class="layui-input" id="keyfileId1">
                        </div>
                    </div>
                    <div class="layui-form-item">

                      <label class="layui-form-label">首页背景图</label>

                      <div class="layui-input-block">
                        <div class="clearfix">

                          <div class="uploadSource_img uploadSource_img_img" onclick="uploadImg(this,'img')">

                              <?php if(empty($msg['indeximg'])): ?>
                              <i class="pear-icon pear-icon-add-bold" style="font-size: 50px;line-height: 80px;"></i>
                              <?php else: ?> 
                              <img src="/static/files/iuser/<?php echo htmlentities($msg['indeximg']); ?>" style="width:80px;height:80px;">
                              <?php endif; ?>

                          </div>

                          <input type="file" class="fileUpdate_attrClass_img" accept="image/jpeg,image/png,image/gif" onchange="fileUpdate_attrClassChange(this,'img')"  name="indeximg" style="display:none;">

                        

                      </div>

                    </div>
                    </div>
                    <div class="layui-form-item">

                      <label class="layui-form-label">检测背景图</label>

                      <div class="layui-input-block">
                        <div class="clearfix">

                          <div class="uploadSource_img uploadSource_img_img" onclick="uploadImg(this,'img')">

                              <?php if(empty($msg['indeximg1'])): ?>
                              <i class="pear-icon pear-icon-add-bold" style="font-size: 50px;line-height: 80px;"></i>
                              <?php else: ?> 
                              <img src="/static/files/iuser/<?php echo htmlentities($msg['indeximg1']); ?>" style="width:80px;height:80px;">
                              <?php endif; ?>
                          </div>

                          <input type="file" class="fileUpdate_attrClass_img" accept="image/jpeg,image/png,image/gif" onchange="fileUpdate_attrClassChange(this,'img')"  name="indeximg1" style="display:none;">

                        

                      </div>

                    </div>
                    </div>
                    <div class="layui-col-md6"> 
                      <div class="layui-form-item">
                        <label class="layui-form-label">保存天数</label>
                        <div class="layui-input-block userp_1">
                          <input type="text" name="usedays" value="<?php echo htmlentities((isset($msg['usedays']) && ($msg['usedays'] !== '')?$msg['usedays']:'0')); ?>" lay-verify="required" required   placeholder="请输入用户数据保存天数" autocomplete="off" class="layui-input">
                          <span class="userp_2">天</span>
                          </div>
                      </div>
                      </div>
                    
                    <div class="layui-form-item">
                      <div class="layui-input-block">
                        <button class="pear-btn pear-btn-primary pear-btn-sm" lay-submit lay-filter="form-save"><i class="layui-icon layui-icon-ok"></i>确认信息</button>
                        <button type="reset" class="pear-btn  pear-btn-sm"><i class="layui-icon layui-icon-refresh"></i>重置</button>
                      </div>
                    </div>
                  </form>
            </div>
        </div>
           
        <script>
           function uploadImg(item,name) {

$(item).next(".fileUpdate_attrClass_"+name).click();

};

function fileUpdate_attrClassChange(item,name,px1=80,px2=80){

if ($(item).val()) {

    var imgurl = getObjectURL(item.files[0]);

    $(item).prev(".uploadSource_img").html(`

            <img src="${imgurl}" style="width:${px1}px;height:${px2}px;">

        `);

    }

}
            $(".upFileClass").click(function(){
                $("#keyfileId").click();
            });
            $("#keyfileId").change(function(){
                if($(this).val()){
                    $(".upFileClass").html("已上传");
                    $(".upFileClass").addClass("bkClass");
                    
                }
            });

            $(".upFileClass1").click(function () {
                    $("#keyfileId1").click();
                });
                $("#keyfileId1").change(function () {
                        if ($(this).val()) {
                            $(".upFileClass1").html("已上传");
                            $(".upFileClass1").addClass("bkClass");

                        }
                    });
			layui.use(['table', 'form', 'jquery'], function() {
				let table = layui.table;
				let form = layui.form;
				let $ = layui.jquery;
                form.on('submit(form-save)', function (data) {
                    var data = $("#formId");
                    postDatai("<?php echo url('basic/setWxConfigSave'); ?>", data).then(function (res) {
                        if (res.code == 200) {
                            layer.msg(res.message, {
                                icon: 1,
                                time: 1000
                            }, function () {
                              parent.layui.admin.refreshThis()
                               return; 
                            });
                        } else {
                            layer.msg(res.message, {
                                icon: 2,
                                time: 1000
                            });
                        }
                    });
                    return false;
                });
           

			})
		</script>
</body>

<script>








    //     参数解释  
    //  url 地址  
    //  data  数据  
    //  alt 进度提示内容  
    //  ins 0 手动处理返回信息  1 自动处理返回信息
    //     co[辅助alt  co = 0时  进度条默认关闭  co = 1时  手动关闭进度条及之后弹框的内容]


    //带文件提交
    function postDatai(url, form, alt = "", ins = 0) {
        var p = new Promise(function (resolve, reject) {
            var formData = new FormData(form[0]);
            $.ajax({
                url: url,
                type: 'POST',
                data: formData,
                dataType: 'json',
                async: true,
                processData: false,
                contentType: false,
                success: function (res) {
                    if (res.code == -1) {
                        layer.alert(res.msg, {
                            title: "提示",
                            closeBtn: 0,
                            yes: function () {
                                location.reload();
                            }
                        });
                        return;
                    }
                    if (!ins) {
                        resolve(res);
                        return;
                    }
                    layer.alert(res.msg, {
                        title: "提示",
                        closeBtn: 0,
                        yes: function () {
                            res.code == 200 ? location.reload() : layer.close(layer.index);
                            return;
                        }
                    });


                },
                error: function (e) {
                    var res = $.parseJSON(e.responseText);
                    layer.alert(res.message, {
                        title: '提示',
                        closeBtn: 0,
                    });
                },
                beforeSend: function () {
                    if (alt) {
                        layer.msg(alt, { icon: 16, shade: 0.4, time: false });
                    }

                },
                complete: function () {
                    if (alt) {
                        layer.close(layer.index);
                    }
                }

            });
        })
        return p;
    }




    //普通提交--整改
    function postData(url, data, alt = "", ins = 0, co = 0) {
        var p = new Promise(function (resolve, reject) {
            $.ajax({
                url: url,
                data: data,
                header: { 'content-type': 'application/json' },
                type: 'POST',
                dataType: 'json',
                responseType: 'text',
                success: function (res) {
                    if (res.code == -1) {
                        layer.alert(res.message, {
                            title: "提示",
                            closeBtn: 0,
                            yes: function () {
                                location.reload();
                            }
                        });
                        return;
                    }
                    if (!ins) {
                        resolve(res);
                        return;
                    }
                    layer.alert(res.message, {
                        title: "提示",
                        closeBtn: 0,
                        yes: function () {
                            res.code == 200 ? location.reload() : layer.close(layer.index);
                            return;
                        }
                    });
                },
                fail: function (res) {
                    console.log(res);

                },
                error: function (e) {
                    var res = $.parseJSON(e.responseText);
                    layer.alert(res.message, {
                        title: '提示',
                        closeBtn: 0,
                    });
                },
                beforeSend: function () {
                    if (alt) {
                        layer.msg(alt, { icon: 16, shade: 0.4, time: false });
                    }

                },
                complete: function () {
                    if (alt && co) {
                        layer.close(layer.index);
                    }
                }

            })

        })
        return p;
    }



    function getObjectURL(file) {
		var url = null;
		if (window.createObjectURL != undefined) { // basic
			url = window.createObjectURL(file);
		} else if (window.URL != undefined) { // mozilla(firefox)
			url = window.URL.createObjectURL(file);
		} else if (window.webkitURL != undefined) { // webkit or chrome
			url = window.webkitURL.createObjectURL(file);
		}
		return url;
	}
</script>

</html>